package com.obelisco.vista.controles;

import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Calendar;


import nextapp.echo2.app.event.ActionListener;
import nextapp.echo2.app.event.ActionEvent;
import nextapp.echo2.app.ApplicationInstance;
import nextapp.echo2.app.Color;
import nextapp.echo2.app.Extent;

import echopointng.model.CalendarSelectionListener;
import echopointng.model.DefaultCalendarSelectionModel;;


public class DateField extends echopointng.DateField {

	private int ancho = 200;
	TextField					txtFecha = new TextField(ancho);
	DefaultCalendarSelectionModel	defCalendarSelectionModel = new DefaultCalendarSelectionModel(Calendar.getInstance());

	public DateField() {
		super();
		initComponents();
	}
	
	public DateField(int ancho) {
		super();
		this.ancho = ancho;
		initComponents();
	}

	
	private void initComponents() {
		this.setModel(defCalendarSelectionModel);
		
		defCalendarSelectionModel.addListener(new CalendarSelectionListener() {
			public void displayedDateChange(echopointng.model.CalendarEvent calEvent) {
				defCalendarSelectionModel.setDisplayedDate(calEvent.getCalendar());
				DateField.this.updateTextFromDate();
			};
	
				
			public void selectedDateChange(echopointng.model.CalendarEvent calEvent) {
				defCalendarSelectionModel.setSelectedDate(calEvent.getCalendar());
				DateField.this.updateTextFromDate();

			};
		});
		txtFecha.setWidth(new Extent(ancho));
		txtFecha.setEnabled(false);
		this.setTextField(txtFecha);
		
		this.getDateChooser().setMonthSelectable(true);
		this.getDateChooser().setYearSelectable(true);
		//this.getDateChooser().setLocale(ApplicationInstance.getActive().getLocale());
		this.getDateChooser().setLocale(new Locale("es","VE"));
		this.getDateChooser().setFastMode(true);
		
		this.setPopUpAlwaysOnTop(true);
		this.setFocusOnExpand(true);
		this.updateTextFromDate();
		this.setUpdateFromTextField(true);
	}	
}
